import React from "react";
import ReactDOM from "react-dom/client";

class App extends React.Component {
  handleClick = (name, age) => {
    console.log(name, age);
  };

  render() {
    return (
      <div>
        <h1>App</h1>

        {/* 一、bind 传参 */}
        <button onClick={this.handleClick.bind(this, "张三", 18)}>点我</button>

        {/* 二、内联 + 箭头函数的方式 */}
        <button
          onClick={() => {
            this.handleClick("张三", 18);
          }}
        >
          点我
        </button>
      </div>
    );
  }
}

const root = ReactDOM.createRoot(document.querySelector("#root"));
root.render(<App />);
